package com.cc.mall.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cc.common.utils.PageUtils;
import com.cc.common.utils.R;
import com.cc.mall.dao.RotationChartDao;
import com.cc.mall.entity.RotationChartEntity;
import com.cc.mall.service.RotationChartService;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;


@Service("rotationChartService")
public class RotationChartServiceImpl extends ServiceImpl<RotationChartDao, RotationChartEntity> implements RotationChartService {


    @Override
    public Page<RotationChartEntity> getAllRotationchart(Map<String, Object> params) {
        int curpage = Integer.parseInt((String) params.get("page"));
        int limit = Integer.parseInt((String) params.get("limit"));
        Page<RotationChartEntity> page = new Page<>(curpage,limit);
        this.baseMapper.selectPage(page, new QueryWrapper<RotationChartEntity>());
        List<RotationChartEntity> list = page.getRecords();
        for (RotationChartEntity one:list){
            List<String> rotations = new ArrayList<>();
            rotations.add(one.getRotationChart());
            one.setRotationCharts(rotations);
        }
        return page;
    }

    @Override
    public List<RotationChartEntity> getRotationchart() {
        return this.baseMapper.getRotationchart();
    }
}